/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.moravian.managers;

import edu.moravian.entity.Enemy;

/**
 *
 * @author szilagyi
 */
public class EnemySendThread implements Runnable
{

    private WaveGenerator waveGenerator;
    private EnemyManager enemyManager;

    public EnemySendThread(WaveGenerator waveGenerator, EnemyManager enemyManager)
    {
        this.waveGenerator = waveGenerator;
        this.enemyManager = enemyManager;
    }

    public void run()
    {

        if (waveGenerator.hasNextWave())
        {
            WaveGenerator.Wave newWave = waveGenerator.getNextWave();
            for (Enemy enemy : newWave.getEnemies())
            {
                try
                {
                    enemyManager.addEnemy(enemy);
                    Thread.sleep((long) (newWave.getSendDelay() * 1000));
                }
                catch (InterruptedException ex)
                {
                }
            }
        }
    }

}
